package com.kinyx.framework.data.deserializer;

import java.io.IOException;
import java.util.Date;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import com.kinyx.framework.utils.KDateTimeUtils;

public class JsonDeserializer4Date extends JsonDeserializer<Date> {

	@Override
	public Date deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
		final JsonNode node = p.getCodec().readTree(p);
		return KDateTimeUtils.toDate(node.asText(), null);
	}

}
